export default {
  data() {
    return {
      title: 'Hello',
      penColor: 'red',
      penSize: 5,
      url: '',
      openSmooth: true,
      is: null
    }
  },
  onLoad(e) {
    this.is = e.is
  },
  methods: {
    onClick(type) {
      if (type == 'openSmooth') {
        this.openSmooth = !this.openSmooth
        return
      }
      if (type == 'save') {
        this.$refs.signatureRef.canvasToTempFilePath({
          success: (res) => {
            // 是否为空画板 无签名
            console.log('是否签名?' + res.isEmpty)
            // 生成图片的临时路径
            // app | H5 | 微信小程序 生成的是base64
            this.url = res.tempFilePath
            if (res.isEmpty) {
              let title = '请签名在保存~'
              uni.$showMsg(title)
            } else {
              if (this.is) {
                uni.reLaunch({
                  url: `/subpkg/my-file-contract/my-file-contract?url=${this.url}`
                })
              } else {
                uni.navigateBack({
                  delta: 1, //返回层数，2则上上页
                })
              }


            }
            // console.log(this.url)
          }
        })
        return
      }
      if (this.$refs.signatureRef)
        this.$refs.signatureRef[type]()
    }
  }
}
